<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			* {
				margin: 0;
				padding: 0;
			}

			#myCan {
				display: block;
				margin: 0 auto;
				background-color: lightskyblue;
			}
		</style>
	</head>
	<body>
		<canvas id="myCan" width="400" height="400"></canvas>
		<script type="text/javascript">
			var oC = document.getElementById('myCan');
			var ctx = oC.getContext('2d');
			var oImg = ctx.createImageData(100, 100);
			// 前三行红色
			for(var i=0;i<3000;i++){
				oImg.data[4*i] = 255;
				oImg.data[4*i+1] = 0;
				oImg.data[4*i+2] = 0;
				oImg.data[4*i+3] = 255;
			}
			
			// 绿色
			for(var i=3000;i<6000;i++){
				oImg.data[4*i] = 0;
				oImg.data[4*i+1] = 255;
				oImg.data[4*i+2] = 0;
				oImg.data[4*i+3] = 255;
			}
			
			// 黄色
			for(var i=6000;i<9000;i++){
				oImg.data[4*i] = 255;
				oImg.data[4*i+1] = 255;
				oImg.data[4*i+2] = 0;
				oImg.data[4*i+3] = 255;
			}
			
			// 蓝色
			for(var i=9000;i<10000;i++){
				oImg.data[4*i] = 0;
				oImg.data[4*i+1] = 0;
				oImg.data[4*i+2] = 255;
				oImg.data[4*i+3] = 255;
			}
			ctx.putImageData(oImg,100,100);
		</script>
	</body>
</html>
